/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.susx.inf.ianw.shareManagement.locator;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import uk.ac.susx.inf.ianw.shareManagement.ShareBroker;

public class RMILocator {

    private static RMILocator instance;
    
    private ShareBroker shareBroker;
    
    private RMILocator() throws RemoteException, NotBoundException{
        Registry registry = LocateRegistry.getRegistry(40090);
        shareBroker = (ShareBroker)registry.lookup(ShareBroker.SHAREBROKER);
    }
    
    public static RMILocator getInstance() throws RemoteException, NotBoundException{
        if(instance == null){
            instance = new RMILocator();
        }
        return instance;
    }
    
    public ShareBroker getShareBroker(){
        return shareBroker;
    }
}
